//
//  RankTableViewCell.m
//  海角音乐
//
//  Created by dllo on 15/8/14.
//  Copyright (c) 2015年 杨元石. All rights reserved.
//

#import "RankTableViewCell.h"

@implementation RankTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        CGFloat pic_X = SCREEN_WIDTH*0.0266667; // 10
        _pic_url = [[UIImageView alloc] initWithFrame:CGRectMake(pic_X, pic_X, 105*ADJUSTWIDTH, 105*ADJUSTWIDTH)];
        [self.contentView addSubview:_pic_url];
        [_pic_url release];
        
        
        CGFloat title_X = 125*ADJUSTWIDTH;
        CGFloat title_width = 250*ADJUSTWIDTH; // 200
        CGFloat title_height = 25*ADJUSTWIDTH; // 30
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(title_X, pic_X, title_width, title_height)];
        _title.font = [UIFont boldSystemFontOfSize:16];
        _title.textAlignment = NSTextAlignmentLeft;
        _title.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_title];
        [_title release];
        
        
        CGFloat line_Y = SCREEN_WIDTH*0.1066667; // 40
        
        _line = [[UIView alloc] initWithFrame:CGRectMake(title_X, line_Y, title_width, 1)];
        _line.backgroundColor = [UIColor lightGrayColor];
        _line.alpha = 0.3;
        [self.contentView addSubview:_line];
        [_line release];
        
        
        CGFloat song_X = 125*ADJUSTWIDTH; // 160
        CGFloat song_width = SCREEN_WIDTH*0.53333; // 200
        CGFloat song_Y = SCREEN_WIDTH*0.12; // 45
        CGFloat song_YYY = 24*ADJUSTWIDTH; // 28
        
        for (int i = 0; i < 3; i++) {
            
            _song_name = [[UILabel alloc] initWithFrame:CGRectMake(song_X, song_Y+i*song_YYY, song_width, song_width/10)];
            _song_name.font = [UIFont boldSystemFontOfSize:14];
            _song_name.textColor = [UIColor whiteColor];
            _song_name.tag = 200+i;
            [self.contentView addSubview:_song_name];
            [_song_name release];
        }
        
        
        
    }
    return self;
}


- (void)getDataModel:(RankModel *)rankModel
{
    
    
    [_pic_url sd_setImageWithURL:[NSURL URLWithString:rankModel.pic_url] placeholderImage:[UIImage imageNamed:@"share-default.png"]];
    _title.text = rankModel.title;
    NSArray *songlistArr = rankModel.songlist;
    
    UILabel *song_one = (UILabel *)[self.contentView viewWithTag:200];
    UILabel *song_two = (UILabel *)[self.contentView viewWithTag:201];
    UILabel *song_three = (UILabel *)[self.contentView viewWithTag:202];
    
    NSString *one = [NSString stringWithFormat:@"1.%@", [[songlistArr objectAtIndex:0] objectForKey:@"songName"]];
    NSString *two = [NSString stringWithFormat:@"2.%@", [[songlistArr objectAtIndex:1] objectForKey:@"songName"]];
    NSString *three = [NSString stringWithFormat:@"3.%@", [[songlistArr objectAtIndex:2] objectForKey:@"songName"]];
    song_one.text = one;
    song_two.text = two;
    song_three.text = three;
    
    
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
